package ui;

import java.awt.Dimension;
import java.awt.Font;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SpringLayout;
import ui.Main;

public class GameScoreView extends JPanel {
	
    private JLabel wins, winCount, draws, drawCount, losses, lossCount;
    private String winString = Integer.toString(Main.getWins());
    private String lossString = Integer.toString(Main.getLosses());
    private String drawsString = Integer.toString(Main.getDraws());

    public GameScoreView() {
        init();
    }

    public void init() {
        setBorder(BorderFactory.createTitledBorder("Score: "));
        setLayout(new SpringLayout());

        wins = new JLabel("Wins", JLabel.CENTER);
        wins.setPreferredSize(new Dimension(150, 40));
        winCount = new JLabel(winString, JLabel.CENTER);
        winCount.setPreferredSize(new Dimension(150, 40));
        winCount.setFont(new Font("Arial",Font.BOLD,22));
        
        draws = new JLabel("Draws", JLabel.CENTER);
        draws.setPreferredSize(new Dimension(150, 40));
        drawCount = new JLabel(drawsString, JLabel.CENTER);
        drawCount.setPreferredSize(new Dimension(150, 40));
        drawCount.setFont(new Font("Arial",Font.BOLD,22));
        
        losses = new JLabel("Losses", JLabel.CENTER);
        losses.setPreferredSize(new Dimension(150, 40));
        lossCount = new JLabel(lossString, JLabel.CENTER);
        lossCount.setPreferredSize(new Dimension(150, 40));
        lossCount.setFont(new Font("Arial",Font.BOLD,22));
        
        add(wins);
        add(draws);
        add(losses);
        
        add(winCount);
        add(drawCount);
        add(lossCount);

        SpringUtilities.makeCompactGrid(this,
        2, 3,       //rows, cols
        4, 4,       //initX, initY
        4, 4);      //xPad, yPad
    }
    
    public void refreshScore(){
        winString = Integer.toString(Main.getWins());
        lossString = Integer.toString(Main.getLosses());
        drawsString = Integer.toString(Main.getDraws());
        
        winCount.setText(winString);
        drawCount.setText(drawsString);
        lossCount.setText(lossString);
    }

}
